﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;

namespace HYView
{
	public partial class SelectViewForm : System.Windows.Forms.Form
	{
		public int SelectIndex
		{
			get
			{
				return this.m_selectedIndex;
			}
		}

		public SelectViewForm(List<string> viewNames)
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			this.m_viewNames = viewNames;
			this.InitControlInfo();
		}

		protected void InitControlInfo()
		{
			this.lstUsableView.Items.Clear();
			foreach (string item in this.m_viewNames)
			{
				this.lstUsableView.Items.Add(item);
			}
			this.lstUsableView.SelectedIndex = 0;
		}

		private void btnOpenView_Click(object sender, EventArgs e)
		{
			this.m_selectedIndex = this.lstUsableView.SelectedIndex;
		}

		private void lstUsableView_DoubleClick(object sender, EventArgs e)
		{
			this.m_selectedIndex = this.lstUsableView.SelectedIndex;
			base.DialogResult = DialogResult.OK;
		}

		private void SwitchViewForm_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}

		private List<string> m_viewNames;

		private int m_selectedIndex;
	}
}
